package com.lantian.uavmaterial.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.lantian.uavmaterial.domain.UavFlightcontrolSystem;
import com.lantian.uavmaterial.service.IUavFlightcontrolSystemService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lantian.common.annotation.Log;
import com.lantian.common.core.controller.BaseController;
import com.lantian.common.core.domain.AjaxResult;
import com.lantian.common.enums.BusinessType;
import com.lantian.common.utils.poi.ExcelUtil;
import com.lantian.common.core.page.TableDataInfo;

/**
 * 飞控系统Controller
 * 
 * @author lantian
 * @date 2025-11-06
 */
@RestController
@RequestMapping("/uav/flightcontrol")
public class UavFlightcontrolSystemController extends BaseController
{
    @Autowired
    private IUavFlightcontrolSystemService uavFlightcontrolSystemService;

    /**
     * 查询飞控系统列表
     */
    @PreAuthorize("@ss.hasPermi('uav:flightcontrol:list')")
    @GetMapping("/list")
    public TableDataInfo list(UavFlightcontrolSystem uavFlightcontrolSystem)
    {
        startPage();
        List<UavFlightcontrolSystem> list = uavFlightcontrolSystemService.selectUavFlightcontrolSystemList(uavFlightcontrolSystem);
        return getDataTable(list);
    }

    /**
     * 导出飞控系统列表
     */
    @PreAuthorize("@ss.hasPermi('uav:flightcontrol:export')")
    @Log(title = "飞控系统", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UavFlightcontrolSystem uavFlightcontrolSystem)
    {
        List<UavFlightcontrolSystem> list = uavFlightcontrolSystemService.selectUavFlightcontrolSystemList(uavFlightcontrolSystem);
        ExcelUtil<UavFlightcontrolSystem> util = new ExcelUtil<UavFlightcontrolSystem>(UavFlightcontrolSystem.class);
        util.exportExcel(response, list, "飞控系统数据");
    }

    /**
     * 获取飞控系统详细信息
     */
    @PreAuthorize("@ss.hasPermi('uav:flightcontrol:query')")
    @GetMapping(value = "/{flightControlId}")
    public AjaxResult getInfo(@PathVariable("flightControlId") String flightControlId)
    {
        return success(uavFlightcontrolSystemService.selectUavFlightcontrolSystemByFlightControlId(flightControlId));
    }

    /**
     * 新增飞控系统
     */
    @PreAuthorize("@ss.hasPermi('uav:flightcontrol:add')")
    @Log(title = "飞控系统", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UavFlightcontrolSystem uavFlightcontrolSystem)
    {
        return toAjax(uavFlightcontrolSystemService.insertUavFlightcontrolSystem(uavFlightcontrolSystem));
    }

    /**
     * 修改飞控系统
     */
    @PreAuthorize("@ss.hasPermi('uav:flightcontrol:edit')")
    @Log(title = "飞控系统", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UavFlightcontrolSystem uavFlightcontrolSystem)
    {
        return toAjax(uavFlightcontrolSystemService.updateUavFlightcontrolSystem(uavFlightcontrolSystem));
    }

    /**
     * 删除飞控系统
     */
    @PreAuthorize("@ss.hasPermi('uav:flightcontrol:remove')")
    @Log(title = "飞控系统", businessType = BusinessType.DELETE)
	@DeleteMapping("/{flightControlIds}")
    public AjaxResult remove(@PathVariable String[] flightControlIds)
    {
        return toAjax(uavFlightcontrolSystemService.deleteUavFlightcontrolSystemByFlightControlIds(flightControlIds));
    }
}
